﻿using mfLogger;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace mfLogger.Test
{
    
    
    /// <summary>
    ///This is a test class for mfLogMessageTest and is intended
    ///to contain all mfLogMessageTest Unit Tests
    ///</summary>
    [TestClass()]
    public class mfLogMessageTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for mfLogMessage Constructor
        ///</summary>
        [TestMethod()]
        public void mfLogMessageConstructorTest()
        {
            Exception ex = new Exception("test error");
            mfLogMessage target = new mfLogMessage(ex);

            Assert.AreEqual("test error\r\nStacktrace:\r\n\r\n", target.Text); 

            Assert.AreEqual(enumLogMessageLevel.Error, target.Level);
        }

        /// <summary>
        ///A test for mfLogMessage Constructor
        ///</summary>
        [TestMethod()]
        public void mfLogMessageConstructorTest1()
        {
            enumLogMessageLevel level = enumLogMessageLevel.Warning;
            string text = "test msg"; 
            mfLogMessage target = new mfLogMessage(level, text);

            Assert.AreEqual(text, target.Text);
            Assert.AreEqual(level, target.Level); 
        }

        /// <summary>
        ///A test for mfLogMessage Constructor
        ///</summary>
        [TestMethod()]
        public void mfLogMessageConstructorTest2()
        {
            string text = "test msg";

            mfLogMessage target = new mfLogMessage(text);

            Assert.AreEqual(text, target.Text);
        }

        /// <summary>
        ///A test for ToString
        ///</summary>
        [TestMethod()]
        public void ToStringTest()
        {
            Exception ex = new Exception("test error");
            mfLogMessage target = new mfLogMessage(ex);

            string expected = string.Empty; 
            string actual;

            actual = target.ToString();

            // return TimeStamp + " (" + TranslateEndSensorType(Level) + "): " + Text;
            Assert.AreEqual(target.TimeStamp + " (Error): " + target.Text, actual);
        }

        /// <summary>
        ///A test for TranslateEndSensorType
        ///</summary>
        [TestMethod()]
        public void TranslateEndSensorTypeTest()
        {
            enumLogMessageLevel msgLevel = enumLogMessageLevel.Debug;
            string expected = "Debug";
            string actual;

            actual = mfLogMessage.TranslateEndSensorType(msgLevel);

            Assert.AreEqual(expected, actual);
        }


    }
}
